Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make a static pinning decision based on the last level with data (not bottommost level) (#626) #684

Merged

Conversation

udi-speedb
Copy link
Contributor

No description provided.

@udi-speedb udi-speedb linked an issue Sep 22, 2023 that may be closed by this pull request
return current_->storage_info();
}

int ColumnFamilyData::IsLastLevelWithData(int level) const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

int last_level_with_data = vstorage->num_non_empty_levels() - 1;

auto is_last_level_with_data = false;
if ((level > 0) and (level == last_level_with_data)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"&&" rather than "and" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -68,15 +68,17 @@ TableCache::TableCache(const ImmutableOptions& ioptions,
const FileOptions* file_options, Cache* const cache,
BlockCacheTracer* const block_cache_tracer,
const std::shared_ptr<IOTracer>& io_tracer,
const std::string& db_session_id)
const std::string& db_session_id,
IsLastLevelWithDataFunc is_last_leve_with_data_func)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"is_last_level_with_data_func" (not leve_)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +24 to +25
TablePinningOptions(int _level, bool _is_last_level_with_data,
size_t _file_size, size_t _max_file_size_for_l0_meta_pin)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to have both "last level with data" and "bottom"? I know the current use case does not seem to care about the distinction but I am wondering if it could be important in the future (or if this use case proves to be incomplete).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hilik's intention is clearly to decide based on the last level with data.
If we ever do find a use case for the bottom flag as well, we will add it. I really see no need to have it just in case.

@udi-speedb
Copy link
Contributor Author

udi-speedb commented Sep 23, 2023

@mrambacher I have pushed a commit addressing the issues you have raised.
Are you done with the review?
I need this PR for #660 so, I really need this PR merges soon.
Thanks

Copy link
Contributor

@mrambacher mrambacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with minor comments/suggestions

Comment on lines +7446 to +7453
ASSERT_GT(total_num_pinned_, 0U);
--total_num_pinned_;

ASSERT_GE(usage_, pinned->size);
usage_ -= pinned->size;

if (pinned->is_last_level_with_data) {
ASSERT_GT(num_pinned_last_level_with_data_, 0U);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should probably be EXPECT_xx rather than ASSERT_xx ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why shouldn't it be ASSERT_xx?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why shouldn't it be ASSERT_xx?

In my experience, ASSERT should be when the top-level method is failing whereas EXPECT should be when the failure is a long way from the code.

I would suggest you run an experiment where you hit one of these inner ASSERT statements and observe how the test fails. I often find those deep ASSERT messages hard to trace

Copy link
Contributor Author

@udi-speedb udi-speedb Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, however, the guideline I am following when choosing EXPECT_* rather than ASSERT_* is the following:
"The rule of thumb is to use EXPECT_* when you want the test to continue to reveal more errors after the assertion failure, and use ASSERT_* when continuing after failure doesn’t make sense"

(From the "GoogleTest Primer" on github, for some reason the url fails to work)

db/table_cache.h Outdated
@@ -49,12 +50,16 @@ class HistogramImpl;
// cache, lookup is very fast. The row cache is obtained from
// ioptions.row_cache
class TableCache {
public:
using IsLastLevelWithDataFunc = std::function<int(int level)>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function should return a bool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@udi-speedb udi-speedb force-pushed the 662-static-pinning-incorrect-decision-on-bottom-level branch from 4c3c246 to 218d050 Compare September 26, 2023 02:04
@udi-speedb
Copy link
Contributor Author

@mrambacher Thanks for the review.
I have updated per your last comment, squashed, and forced pushed.

@udi-speedb udi-speedb removed the request for review from Yuval-Ariel September 26, 2023 02:05
@Yuval-Ariel
Copy link
Contributor

@udi-speedb , the CI seems to have failed but the force push removed that commit from this PRs history.. please refrain from force pushing after approval or rerun the CI if you do.
https://github.com/speedb-io/speedb/actions/runs/6302889926/job/17110975186

ninja: job failed: ccache /usr/bin/clang++ -DBZIP2 -DGFLAGS=1 -DGFLAGS_IS_A_DLL=0 -DHAVE_PCLMUL -DHAVE_SSE42 -DLZ4 -DOS_LINUX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_LIB_IO_POSIX -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_NO_DYNAMIC_EXTENSION -DROCKSDB_PLATFORM_POSIX -DROCKSDB_PORTABLE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -DSNAPPY -DZLIB -DZSTD -I../ -I../include -isystem ../third-party/gtest-1.8.1/fused-src -W -Wextra -Wall -pthread -Wsign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-strict-aliasing -Wno-invalid-offsetof -Werror -g -DROCKSDB_USE_RTTI -std=gnu++17 -MD -MT CMakeFiles/db_test.dir/db/db_test.cc.o -MF CMakeFiles/db_test.dir/db/db_test.cc.o.d -o CMakeFiles/db_test.dir/db/db_test.cc.o -c ../db/db_test.cc
../db/db_test.cc:7462:15: error: 'ToString' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
  std::string ToString() const {
              ^
../include/rocksdb/table_pinning_policy.h:94:23: note: overridden virtual function is here
  virtual std::string ToString() const = 0;
                      ^
1 error generated.

@udi-speedb
Copy link
Contributor Author

@Yuval-Ariel

  1. Can't refrain from forced push. PR was approved and I had to squash my commits. We need to decide what to do about forced push.
  2. How come tests have passed before the forced push? Unless I am mistaken, the changes introduced by the forced push are not those causing the CI to fail now.

@udi-speedb
Copy link
Contributor Author

@Yuval-Ariel As I have already noted. If a forced push introduces code changes (not squash / commit message changes only), the CI should automatically restart and merge should be blocked as long as it doesn't pass the CI

@udi-speedb udi-speedb force-pushed the 662-static-pinning-incorrect-decision-on-bottom-level branch from 218d050 to 6784aad Compare September 26, 2023 08:41
@udi-speedb
Copy link
Contributor Author

udi-speedb commented Sep 26, 2023

@Yuval-Ariel - Manual run of the CI passed

Please merge
Screenshot from 2023-09-26 21-35-13

@Yuval-Ariel
Copy link
Contributor

thats actually the main branch (fc2bee8).. i've run it on 6784aad and it passed.
in any case, shouldnt this go through performance before it can be merged?

@udi-speedb
Copy link
Contributor Author

thats actually the main branch (fc2bee8).. i've run it on 6784aad and it passed. in any case, shouldnt this go through performance before it can be merged?

I see. Well, It's always good to know that our main branch passes the CI.
I will make sure I know how to run the CI on the desired branch next time :-)

As for performance, you are correct. Thanks

@udi-speedb
Copy link
Contributor Author

@erez-speedb Please run performace tests on this branch. Thanks

@udi-speedb
Copy link
Contributor Author

@erez-speedb - Please update on the results of the performance testing and if we may merge this pr or do something else. Thanks

@udi-speedb udi-speedb merged commit ab9df1a into main Oct 17, 2023
20 checks passed
@Yuval-Ariel Yuval-Ariel deleted the 662-static-pinning-incorrect-decision-on-bottom-level branch October 17, 2023 19:08
udi-speedb added a commit that referenced this pull request Nov 23, 2023
udi-speedb added a commit that referenced this pull request Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Static Pinning: Incorrect decision on bottom level
3 participants