Skip to content

Commit

Permalink
Revert "container-encapsulate: make build_mapping_recurse significant…
Browse files Browse the repository at this point in the history
…ly faster"

This reverts commit b1da09c.
  • Loading branch information
tymlipari committed Mar 28, 2024
1 parent b1da09c commit 23765ef
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 370 deletions.
92 changes: 19 additions & 73 deletions rpmostree-cxxrs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,6 @@ using ClientConnection = ::rpmostreecxx::ClientConnection;
using RPMDiff = ::rpmostreecxx::RPMDiff;
using RpmOstreeDiffPrintFormat = ::rpmostreecxx::RpmOstreeDiffPrintFormat;
using Progress = ::rpmostreecxx::Progress;
using RpmFileDb = ::rpmostreecxx::RpmFileDb;
using RpmTs = ::rpmostreecxx::RpmTs;
using PackageMeta = ::rpmostreecxx::PackageMeta;
}
Expand Down Expand Up @@ -2812,9 +2811,6 @@ extern "C"
::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$complete_rpm_layering (::std::int32_t rootfs) noexcept;

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (::std::int32_t rootfs) noexcept;

::rust::repr::PtrLen rpmostreecxx$cxxbridge1$passwd_cleanup (::std::int32_t rootfs) noexcept;

::rust::repr::PtrLen rpmostreecxx$cxxbridge1$migrate_group_except_root (
Expand Down Expand Up @@ -2944,6 +2940,9 @@ extern "C"
void rpmostreecxx$cxxbridge1$cache_branch_to_nevra (::rust::Str nevra,
::rust::String *return$) noexcept;

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (::std::int32_t rootfs) noexcept;

::std::uint32_t
rpmostreecxx$cxxbridge1$CxxGObjectArray$length (::rpmostreecxx::CxxGObjectArray &self) noexcept
{
Expand Down Expand Up @@ -3239,17 +3238,17 @@ extern "C"
}

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$RpmFileDb$find_pkgs_for_file (
::rpmostreecxx::RpmFileDb const &self, ::rust::Str path,
rpmostreecxx$cxxbridge1$RpmTs$packages_providing_file (
::rpmostreecxx::RpmTs const &self, ::rust::Str path,
::rust::Vec< ::rust::String> *return$) noexcept
{
::rust::Vec< ::rust::String> (::rpmostreecxx::RpmFileDb::*find_pkgs_for_file$) (::rust::Str)
::rust::Vec< ::rust::String> (::rpmostreecxx::RpmTs::*packages_providing_file$) (::rust::Str)
const
= &::rpmostreecxx::RpmFileDb::find_pkgs_for_file;
= &::rpmostreecxx::RpmTs::packages_providing_file;
::rust::repr::PtrLen throw$;
::rust::behavior::trycatch (
[&] {
new (return$)::rust::Vec< ::rust::String> ((self.*find_pkgs_for_file$) (path));
new (return$)::rust::Vec< ::rust::String> ((self.*packages_providing_file$) (path));
throw$.ptr = nullptr;
},
::rust::detail::Fail (throw$));
Expand All @@ -3273,25 +3272,6 @@ extern "C"
return throw$;
}

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$RpmTs$build_file_cache_from_rpmdb (
::rpmostreecxx::RpmTs const &self, ::rpmostreecxx::GFile const &fs_root,
::rpmostreecxx::RpmFileDb **return$) noexcept
{
::std::unique_ptr< ::rpmostreecxx::RpmFileDb> (
::rpmostreecxx::RpmTs::*build_file_cache_from_rpmdb$) (::rpmostreecxx::GFile const &) const
= &::rpmostreecxx::RpmTs::build_file_cache_from_rpmdb;
::rust::repr::PtrLen throw$;
::rust::behavior::trycatch (
[&] {
new (return$)::rpmostreecxx::RpmFileDb *(
(self.*build_file_cache_from_rpmdb$) (fs_root).release ());
throw$.ptr = nullptr;
},
::rust::detail::Fail (throw$));
return throw$;
}

::std::uint64_t
rpmostreecxx$cxxbridge1$PackageMeta$size (::rpmostreecxx::PackageMeta const &self) noexcept
{
Expand Down Expand Up @@ -5708,16 +5688,6 @@ complete_rpm_layering (::std::int32_t rootfs)
}
}

void
deduplicate_tmpfiles_entries (::std::int32_t rootfs)
{
::rust::repr::PtrLen error$ = rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (rootfs);
if (error$.ptr)
{
throw ::rust::impl< ::rust::Error>::error (error$);
}
}

void
passwd_cleanup (::std::int32_t rootfs)
{
Expand Down Expand Up @@ -6124,6 +6094,16 @@ cache_branch_to_nevra (::rust::Str nevra) noexcept
rpmostreecxx$cxxbridge1$cache_branch_to_nevra (nevra, &return$.value);
return ::std::move (return$.value);
}

void
deduplicate_tmpfiles_entries (::std::int32_t rootfs)
{
::rust::repr::PtrLen error$ = rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (rootfs);
if (error$.ptr)
{
throw ::rust::impl< ::rust::Error>::error (error$);
}
}
} // namespace rpmostreecxx

extern "C"
Expand Down Expand Up @@ -6436,41 +6416,6 @@ extern "C"
{
::rust::deleter_if< ::rust::detail::is_complete< ::rpmostreecxx::PackageMeta>::value>{}(ptr);
}

static_assert (::rust::detail::is_complete< ::rpmostreecxx::RpmFileDb>::value,
"definition of RpmFileDb is required");
static_assert (sizeof (::std::unique_ptr< ::rpmostreecxx::RpmFileDb>) == sizeof (void *), "");
static_assert (alignof (::std::unique_ptr< ::rpmostreecxx::RpmFileDb>) == alignof (void *), "");
void
cxxbridge1$unique_ptr$rpmostreecxx$RpmFileDb$null (
::std::unique_ptr< ::rpmostreecxx::RpmFileDb> *ptr) noexcept
{
::new (ptr)::std::unique_ptr< ::rpmostreecxx::RpmFileDb> ();
}
void
cxxbridge1$unique_ptr$rpmostreecxx$RpmFileDb$raw (
::std::unique_ptr< ::rpmostreecxx::RpmFileDb> *ptr, ::rpmostreecxx::RpmFileDb *raw) noexcept
{
::new (ptr)::std::unique_ptr< ::rpmostreecxx::RpmFileDb> (raw);
}
::rpmostreecxx::RpmFileDb const *
cxxbridge1$unique_ptr$rpmostreecxx$RpmFileDb$get (
::std::unique_ptr< ::rpmostreecxx::RpmFileDb> const &ptr) noexcept
{
return ptr.get ();
}
::rpmostreecxx::RpmFileDb *
cxxbridge1$unique_ptr$rpmostreecxx$RpmFileDb$release (
::std::unique_ptr< ::rpmostreecxx::RpmFileDb> &ptr) noexcept
{
return ptr.release ();
}
void
cxxbridge1$unique_ptr$rpmostreecxx$RpmFileDb$drop (
::std::unique_ptr< ::rpmostreecxx::RpmFileDb> *ptr) noexcept
{
::rust::deleter_if< ::rust::detail::is_complete< ::rpmostreecxx::RpmFileDb>::value>{}(ptr);
}
} // extern "C"

namespace rust
Expand Down Expand Up @@ -6873,5 +6818,6 @@ Vec< ::rpmostreecxx::LockedPackage>::truncate (::std::size_t len)
{
return cxxbridge1$rust_vec$rpmostreecxx$LockedPackage$truncate (this, len);
}

} // namespace cxxbridge1
} // namespace rust
5 changes: 2 additions & 3 deletions rpmostree-cxxrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,6 @@ using ClientConnection = ::rpmostreecxx::ClientConnection;
using RPMDiff = ::rpmostreecxx::RPMDiff;
using RpmOstreeDiffPrintFormat = ::rpmostreecxx::RpmOstreeDiffPrintFormat;
using Progress = ::rpmostreecxx::Progress;
using RpmFileDb = ::rpmostreecxx::RpmFileDb;
using RpmTs = ::rpmostreecxx::RpmTs;
using PackageMeta = ::rpmostreecxx::PackageMeta;
}
Expand Down Expand Up @@ -2016,8 +2015,6 @@ bool prepare_rpm_layering (::std::int32_t rootfs, ::rust::Str merge_passwd_dir);

void complete_rpm_layering (::std::int32_t rootfs);

void deduplicate_tmpfiles_entries (::std::int32_t rootfs);

void passwd_cleanup (::std::int32_t rootfs);

void migrate_group_except_root (::std::int32_t rootfs,
Expand Down Expand Up @@ -2060,4 +2057,6 @@ ::rpmostreecxx::GKeyFile *treefile_to_origin (::rpmostreecxx::Treefile const &tf
void origin_validate_roundtrip (::rpmostreecxx::GKeyFile const &kf) noexcept;

::rust::String cache_branch_to_nevra (::rust::Str nevra) noexcept;

void deduplicate_tmpfiles_entries (::std::int32_t rootfs);
} // namespace rpmostreecxx
9 changes: 4 additions & 5 deletions rust/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl From<MappingBuilder> for ObjectMeta {
fn build_mapping_recurse(
path: &mut Utf8PathBuf,
dir: &gio::File,
file_cache: &crate::ffi::RpmFileDb,
ts: &crate::ffi::RpmTs,
state: &mut MappingBuilder,
) -> Result<()> {
use std::collections::btree_map::Entry;
Expand All @@ -155,7 +155,7 @@ fn build_mapping_recurse(
continue;
}

let mut pkgs = file_cache.find_pkgs_for_file(path.as_str())?;
let mut pkgs = ts.packages_providing_file(path.as_str())?;
// Let's be deterministic (but _unstable because we don't care about behavior of equal strings)
pkgs.sort_unstable();
// For now, we pick the alphabetically first package providing a file
Expand Down Expand Up @@ -192,7 +192,7 @@ fn build_mapping_recurse(
}
}
gio::FileType::Directory => {
build_mapping_recurse(path, &child, file_cache, state)?;
build_mapping_recurse(path, &child, ts, state)?;
}
o => anyhow::bail!("Unhandled file type: {}", o),
}
Expand Down Expand Up @@ -379,8 +379,7 @@ pub fn container_encapsulate(args: Vec<String>) -> CxxResult<()> {

// Walk the filesystem
progress_task("Building package mapping", || {
let file_cache = q.build_file_cache_from_rpmdb(root.reborrow_cxx())?;
build_mapping_recurse(&mut Utf8PathBuf::from("/"), &root, &file_cache, &mut state)
build_mapping_recurse(&mut Utf8PathBuf::from("/"), &root, &q, &mut state)
})?;

let src_pkgs: HashSet<_> = state.packagemeta.iter().map(|p| &p.srcid).collect();
Expand Down
2 changes: 1 addition & 1 deletion rust/src/cxxrsutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ cxxrs_bind!(
[Deployment, Repo, RepoTransactionStats, SePolicy, Sysroot]
);
cxxrs_bind!(G, glib, glib::gobject_ffi, [Object]);
cxxrs_bind!(G, gio, gio::ffi, [Cancellable, DBusConnection, File, FileInfo]);
cxxrs_bind!(G, gio, gio::ffi, [Cancellable, DBusConnection, FileInfo]);
cxxrs_bind!(G, glib, glib::ffi, [KeyFile, Variant, VariantDict]);

/// Error type helpers; separate from the GObject bridging.
Expand Down
8 changes: 1 addition & 7 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub mod ffi {
type GObject = crate::FFIGObject;
type GCancellable = crate::FFIGCancellable;
type GDBusConnection = crate::FFIGDBusConnection;
type GFile = crate::FFIGFile;
type GFileInfo = crate::FFIGFileInfo;
type GVariant = crate::FFIGVariant;
type GVariantDict = crate::FFIGVariantDict;
Expand Down Expand Up @@ -895,8 +894,6 @@ pub mod ffi {
unsafe extern "C++" {
include!("rpmostree-rpm-util.h");
#[allow(missing_debug_implementations)]
type RpmFileDb;
#[allow(missing_debug_implementations)]
type RpmTs;
#[allow(missing_debug_implementations)]
type PackageMeta;
Expand All @@ -908,12 +905,9 @@ pub mod ffi {
fn rpmts_for_commit(repo: &OstreeRepo, rev: &str) -> Result<UniquePtr<RpmTs>>;
fn rpmdb_package_name_list(dfd: i32, path: String) -> Result<Vec<String>>;

// Methods on RpmFileDb
fn find_pkgs_for_file(self: &RpmFileDb, path: &str) -> Result<Vec<String>>;

// Methods on RpmTs
fn packages_providing_file(self: &RpmTs, path: &str) -> Result<Vec<String>>;
fn package_meta(self: &RpmTs, name: &str) -> Result<UniquePtr<PackageMeta>>;
fn build_file_cache_from_rpmdb(self: &RpmTs, fs_root: &GFile) -> Result<UniquePtr<RpmFileDb>>;

// Methods on PackageMeta
fn size(self: &PackageMeta) -> u64;
Expand Down
1 change: 0 additions & 1 deletion src/libpriv/rpmostree-cxxrs-prelude.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ typedef ::OstreeSePolicy OstreeSePolicy;
typedef ::GObject GObject;
typedef ::GCancellable GCancellable;
typedef ::GDBusConnection GDBusConnection;
typedef ::GFile GFile;
typedef ::GFileInfo GFileInfo;
typedef ::GVariant GVariant;
typedef ::GVariantDict GVariantDict;
Expand Down
Loading

0 comments on commit 23765ef

Please sign in to comment.