Refactor GetFreshnessLifetimes to Extract Cache-Control Once [chromium/src : main]

1 view
Skip to first unread message

Mayur Patil (Gerrit)

unread,
Feb 27, 2025, 8:11:30 PM2/27/25
to Adam Rice, Chromium LUCI CQ, chromium...@chromium.org, gavin...@chromium.org, net-r...@chromium.org
Attention needed from Adam Rice

Mayur Patil voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
Gerrit-Change-Number: 6310135
Gerrit-PatchSet: 2
Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
Gerrit-Attention: Adam Rice <ri...@chromium.org>
Gerrit-Comment-Date: Fri, 28 Feb 2025 01:11:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

suresh potti (Gerrit)

unread,
Feb 28, 2025, 5:21:54 AM2/28/25
to Mayur Patil, Maks Orlovich, Adam Rice, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
Attention needed from Adam Rice, Maks Orlovich and Mayur Patil

suresh potti added 4 comments

File net/http/http_response_headers.cc
Line 806, Patchset 2 (Latest): base::flat_set<std::string_view> values;

size_t iter = 0;
std::optional<std::string_view> value;
while ((value = EnumerateHeader(&iter, name))) {
values.insert(*value);
}

return values;
suresh potti . unresolved
nit : refactoring
base::flat_set<std::string_view> values;
for (size_t iter = 0; auto value = EnumerateHeader(&iter, name); ) {
values.insert(*value);
}
return values;
Line 817, Patchset 2 (Latest):base::flat_set<std::string_view>
HttpResponseHeaders::GetCacheControlHeaderValues() const {
return GetHeaderValues("cache-control");
}
suresh potti . unresolved

nit : is explicit function required ?

Line 946, Patchset 2 (Latest): base::flat_set<std::string_view> cache_control_values) const {
suresh potti . unresolved

const base::flat_set<std::string_view>&

Line 1424, Patchset 2 (Latest): base::flat_set<std::string_view> cache_control_values) const {
suresh potti . unresolved

const base::flat_set<std::string_view>&

Open in Gerrit

Related details

Attention is currently required from:
  • Adam Rice
  • Maks Orlovich
  • Mayur Patil
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
    Gerrit-Change-Number: 6310135
    Gerrit-PatchSet: 2
    Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
    Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
    Gerrit-CC: suresh potti <sures...@microsoft.com>
    Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Attention: Mayur Patil <patil...@microsoft.com>
    Gerrit-Comment-Date: Fri, 28 Feb 2025 10:21:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Maks Orlovich (Gerrit)

    unread,
    Feb 28, 2025, 9:33:46 AM2/28/25
    to Mayur Patil, suresh potti, Adam Rice, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Adam Rice and Mayur Patil

    Maks Orlovich added 4 comments

    Patchset-level comments
    File-level comment, Patchset 2 (Latest):
    Maks Orlovich . resolved

    ...Have you actually measured this?

    File net/http/http_response_headers.cc
    Line 811, Patchset 2 (Latest): values.insert(*value);
    Maks Orlovich . unresolved
    Line 817, Patchset 2 (Latest):base::flat_set<std::string_view>
    HttpResponseHeaders::GetCacheControlHeaderValues() const {
    return GetHeaderValues("cache-control");
    }
    suresh potti . unresolved

    nit : is explicit function required ?

    Maks Orlovich

    Possibly inline, though LTO and the like likely takes care of that.

    Line 1465, Patchset 2 (Latest): base::flat_set<std::string_view> cache_control_values) const {
    Maks Orlovich . unresolved

    const ref here, too.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Mayur Patil
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
    Gerrit-Change-Number: 6310135
    Gerrit-PatchSet: 2
    Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
    Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
    Gerrit-CC: suresh potti <sures...@microsoft.com>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Attention: Mayur Patil <patil...@microsoft.com>
    Gerrit-Comment-Date: Fri, 28 Feb 2025 14:33:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: suresh potti <sures...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mayur Patil (Gerrit)

    unread,
    Feb 28, 2025, 11:53:14 AM2/28/25
    to suresh potti, Maks Orlovich, Adam Rice, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Adam Rice and Maks Orlovich

    Mayur Patil added 1 comment

    File net/http/http_response_headers.cc
    Line 811, Patchset 2 (Latest): values.insert(*value);
    Maks Orlovich . unresolved

    Don't insert into a flat_set one-by-one. That's quadratic.

    Instead, insert into a vector and move it into a flat_set, using this constructor:
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/flat_set.h;drc=025a94257380eadfad2d705129e5863fca0bf89e;l=58

    (which ends up here:
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/flat_tree.h;drc=58fb75d86a0ad2642beec2d6c16b1e6c008e33cd;l=539
    )

    Mayur Patil

    Generally, cache control values to be set upto 3 from usage perspective.
    Does it go beyond that.
    So Insertion should not be expensive compared to creation of vector and moving to flat_set right?
    Could you share your opinion on this thought process?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Maks Orlovich
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
    Gerrit-Change-Number: 6310135
    Gerrit-PatchSet: 2
    Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
    Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
    Gerrit-CC: suresh potti <sures...@microsoft.com>
    Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Comment-Date: Fri, 28 Feb 2025 16:53:02 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Maks Orlovich <morl...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Maks Orlovich (Gerrit)

    unread,
    Feb 28, 2025, 12:28:56 PM2/28/25
    to Mayur Patil, suresh potti, Adam Rice, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Adam Rice and Mayur Patil

    Maks Orlovich added 1 comment

    File net/http/http_response_headers.cc
    Line 811, Patchset 2 (Latest): values.insert(*value);
    Maks Orlovich . unresolved

    Don't insert into a flat_set one-by-one. That's quadratic.

    Instead, insert into a vector and move it into a flat_set, using this constructor:
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/flat_set.h;drc=025a94257380eadfad2d705129e5863fca0bf89e;l=58

    (which ends up here:
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/flat_tree.h;drc=58fb75d86a0ad2642beec2d6c16b1e6c008e33cd;l=539
    )

    Mayur Patil

    Generally, cache control values to be set upto 3 from usage perspective.
    Does it go beyond that.
    So Insertion should not be expensive compared to creation of vector and moving to flat_set right?
    Could you share your opinion on this thought process?

    Maks Orlovich

    So creating a vector and moving to flat_set is basically sort of free in that flat_set wraps a vector anyway (see the second of the links above). What's not 100% obvious is that on reasonable number of values doing the sort all at once is cheaper than inserting stuff in right spot one by one, even if it's n*log n instead of n^2.

    Of course, if there are 3 values it's unclear that a flat_set is actually useful in the first place.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Mayur Patil
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
    Gerrit-Change-Number: 6310135
    Gerrit-PatchSet: 2
    Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
    Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
    Gerrit-CC: suresh potti <sures...@microsoft.com>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Attention: Mayur Patil <patil...@microsoft.com>
    Gerrit-Comment-Date: Fri, 28 Feb 2025 17:28:46 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Maks Orlovich <morl...@chromium.org>
    Comment-In-Reply-To: Mayur Patil <patil...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mayur Patil (Gerrit)

    unread,
    Feb 28, 2025, 1:20:07 PM2/28/25
    to suresh potti, Maks Orlovich, Adam Rice, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Adam Rice, Maks Orlovich and suresh potti

    Mayur Patil added 7 comments

    Patchset-level comments
    File-level comment, Patchset 2:
    Maks Orlovich . unresolved

    ...Have you actually measured this?

    Mayur Patil

    Thanks for suggesting this point Maks...

    I added a simple Logger to verify Time difference in NanoSeconds for one Parameterized Test Case (RequiresValidationTest.RequiresValidation)...

    Added below snippet:

          const auto startTime =  base::TimeTicks::Now();
    FreshnessLifetimes lifetimes = GetFreshnessLifetimes(response_time);
    const auto endTime = base::TimeTicks::Now();
    LOG(INFO) << "Time difference = " << (endTime - startTime).InNanoseconds();

    Performance of HasHeaderValue lookup is still better compared to storage based lookup validation...

    Performance:-
    HasHeaderValue < Changes without vector while creating flat_set object < Changes with vector while creating flat_set object

    with HasHeaderValue lookup 5 times been highest performant...

    File net/http/http_response_headers.cc
    Line 811, Patchset 2: values.insert(*value);
    Maks Orlovich . unresolved

    Don't insert into a flat_set one-by-one. That's quadratic.

    Instead, insert into a vector and move it into a flat_set, using this constructor:
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/flat_set.h;drc=025a94257380eadfad2d705129e5863fca0bf89e;l=58

    (which ends up here:
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/flat_tree.h;drc=58fb75d86a0ad2642beec2d6c16b1e6c008e33cd;l=539
    )

    Mayur Patil

    Generally, cache control values to be set upto 3 from usage perspective.
    Does it go beyond that.
    So Insertion should not be expensive compared to creation of vector and moving to flat_set right?
    Could you share your opinion on this thought process?

    Maks Orlovich

    So creating a vector and moving to flat_set is basically sort of free in that flat_set wraps a vector anyway (see the second of the links above). What's not 100% obvious is that on reasonable number of values doing the sort all at once is cheaper than inserting stuff in right spot one by one, even if it's n*log n instead of n^2.

    Of course, if there are 3 values it's unclear that a flat_set is actually useful in the first place.

    Mayur Patil

    Made necessary changes to incorporate vector

    Line 806, Patchset 2: base::flat_set<std::string_view> values;


    size_t iter = 0;
    std::optional<std::string_view> value;
    while ((value = EnumerateHeader(&iter, name))) {
    values.insert(*value);
    }

    return values;
    suresh potti . resolved
    nit : refactoring
    base::flat_set<std::string_view> values;
    for (size_t iter = 0; auto value = EnumerateHeader(&iter, name); ) {
    values.insert(*value);
    }
    return values;
    Mayur Patil

    Done

    Line 817, Patchset 2:base::flat_set<std::string_view>

    HttpResponseHeaders::GetCacheControlHeaderValues() const {
    return GetHeaderValues("cache-control");
    }
    suresh potti . resolved

    nit : is explicit function required ?

    Maks Orlovich

    Possibly inline, though LTO and the like likely takes care of that.

    Mayur Patil

    Done

    Line 946, Patchset 2: base::flat_set<std::string_view> cache_control_values) const {
    suresh potti . resolved

    const base::flat_set<std::string_view>&

    Mayur Patil

    Done

    Line 1424, Patchset 2: base::flat_set<std::string_view> cache_control_values) const {
    suresh potti . resolved

    const base::flat_set<std::string_view>&

    Mayur Patil

    Done

    Line 1465, Patchset 2: base::flat_set<std::string_view> cache_control_values) const {
    Maks Orlovich . resolved

    const ref here, too.

    Mayur Patil

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Maks Orlovich
    • suresh potti
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
    Gerrit-Change-Number: 6310135
    Gerrit-PatchSet: 2
    Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
    Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
    Gerrit-CC: suresh potti <sures...@microsoft.com>
    Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Attention: suresh potti <sures...@microsoft.com>
    Gerrit-Comment-Date: Fri, 28 Feb 2025 18:19:55 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Maks Orlovich <morl...@chromium.org>
    Comment-In-Reply-To: Mayur Patil <patil...@microsoft.com>
    Comment-In-Reply-To: suresh potti <sures...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Mar 2, 2025, 10:58:09 PM3/2/25
    to Mayur Patil, suresh potti, Maks Orlovich, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Maks Orlovich, Mayur Patil and suresh potti

    Adam Rice added 1 comment

    Patchset-level comments
    Maks Orlovich . unresolved

    ...Have you actually measured this?

    Mayur Patil

    Thanks for suggesting this point Maks...

    I added a simple Logger to verify Time difference in NanoSeconds for one Parameterized Test Case (RequiresValidationTest.RequiresValidation)...

    Added below snippet:

          const auto startTime =  base::TimeTicks::Now();
    FreshnessLifetimes lifetimes = GetFreshnessLifetimes(response_time);
    const auto endTime = base::TimeTicks::Now();
    LOG(INFO) << "Time difference = " << (endTime - startTime).InNanoseconds();

    Performance of HasHeaderValue lookup is still better compared to storage based lookup validation...

    Performance:-
    HasHeaderValue < Changes without vector while creating flat_set object < Changes with vector while creating flat_set object

    with HasHeaderValue lookup 5 times been highest performant...

    Adam Rice

    Thanks for doing this measurement! It looks like we are losing so much time from doing the memory allocation for the flat_set that it is cancelling out any benefit from reducing the number of string comparisons.

    I suggest giving up on the generic approach and just having a single `EnumerateHeader()` loop in `GetFreshnessLifetimes()` that checks for all 5 strings at the same time.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Maks Orlovich
    • Mayur Patil
    • suresh potti
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
    Gerrit-Change-Number: 6310135
    Gerrit-PatchSet: 3
    Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
    Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
    Gerrit-CC: suresh potti <sures...@microsoft.com>
    Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
    Gerrit-Attention: Mayur Patil <patil...@microsoft.com>
    Gerrit-Attention: suresh potti <sures...@microsoft.com>
    Gerrit-Comment-Date: Mon, 03 Mar 2025 03:58:00 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mayur Patil (Gerrit)

    unread,
    Mar 3, 2025, 2:36:37 PM3/3/25
    to suresh potti, Maks Orlovich, Adam Rice, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Adam Rice, Maks Orlovich and suresh potti

    Mayur Patil added 2 comments

    Patchset-level comments
    Maks Orlovich . unresolved

    ...Have you actually measured this?

    Mayur Patil

    Thanks for suggesting this point Maks...

    I added a simple Logger to verify Time difference in NanoSeconds for one Parameterized Test Case (RequiresValidationTest.RequiresValidation)...

    Added below snippet:

          const auto startTime =  base::TimeTicks::Now();
    FreshnessLifetimes lifetimes = GetFreshnessLifetimes(response_time);
    const auto endTime = base::TimeTicks::Now();
    LOG(INFO) << "Time difference = " << (endTime - startTime).InNanoseconds();

    Performance of HasHeaderValue lookup is still better compared to storage based lookup validation...

    Performance:-
    HasHeaderValue < Changes without vector while creating flat_set object < Changes with vector while creating flat_set object

    with HasHeaderValue lookup 5 times been highest performant...

    Adam Rice

    Thanks for doing this measurement! It looks like we are losing so much time from doing the memory allocation for the flat_set that it is cancelling out any benefit from reducing the number of string comparisons.

    I suggest giving up on the generic approach and just having a single `EnumerateHeader()` loop in `GetFreshnessLifetimes()` that checks for all 5 strings at the same time.

    Mayur Patil

    I have added variables to store computed values.

    Upon reviewing the test results, I noticed an improvement compared to the current values. However, the scope of testing was limited to the RequiresValidation Test Case in this scenario.

    I have a few queries:

    The methods GetMaxAgeValue() and GetStaleWhileRevalidateValue() internally call private method GetCacheControlDirective(). These methods are now only used in test cases. Should we consider removing them and modifying the test cases if these changes are good to go?

    File net/http/http_response_headers.cc
    Line 811, Patchset 2: values.insert(*value);
    Maks Orlovich . resolved

    Don't insert into a flat_set one-by-one. That's quadratic.

    Instead, insert into a vector and move it into a flat_set, using this constructor:
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/flat_set.h;drc=025a94257380eadfad2d705129e5863fca0bf89e;l=58

    (which ends up here:
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/flat_tree.h;drc=58fb75d86a0ad2642beec2d6c16b1e6c008e33cd;l=539
    )

    Mayur Patil

    Generally, cache control values to be set upto 3 from usage perspective.
    Does it go beyond that.
    So Insertion should not be expensive compared to creation of vector and moving to flat_set right?
    Could you share your opinion on this thought process?

    Maks Orlovich

    So creating a vector and moving to flat_set is basically sort of free in that flat_set wraps a vector anyway (see the second of the links above). What's not 100% obvious is that on reasonable number of values doing the sort all at once is cheaper than inserting stuff in right spot one by one, even if it's n*log n instead of n^2.

    Of course, if there are 3 values it's unclear that a flat_set is actually useful in the first place.

    Mayur Patil

    Made necessary changes to incorporate vector

    Mayur Patil

    Approach is changed in favour of variable usage.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Maks Orlovich
    • suresh potti
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
    Gerrit-Change-Number: 6310135
    Gerrit-PatchSet: 4
    Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
    Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
    Gerrit-CC: suresh potti <sures...@microsoft.com>
    Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Attention: suresh potti <sures...@microsoft.com>
    Gerrit-Comment-Date: Mon, 03 Mar 2025 19:36:26 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Maks Orlovich <morl...@chromium.org>
    Comment-In-Reply-To: Adam Rice <ri...@chromium.org>
    Comment-In-Reply-To: Mayur Patil <patil...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Mar 4, 2025, 2:24:41 AM3/4/25
    to Mayur Patil, suresh potti, Maks Orlovich, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Maks Orlovich, Mayur Patil and suresh potti

    Adam Rice added 6 comments

    File net/http/http_response_headers.h
    Line 567, Patchset 4 (Latest): std::optional<base::TimeDelta> ParseCacheControlDirective(
    Adam Rice . unresolved

    This calling convention is a bit confusing. I suggest you change the function to just expect a number like `"3600"` and then in the caller do `value->substr(kMaxAge.size())`. Then you can rename the function so something like `ParseSeconds()` or similar.

    Line 563, Patchset 4 (Latest): // @param directive_size The length of the directive name including the equals
    Adam Rice . unresolved

    We don't normally use `@param` notation in Chromium code. I suggest just describing the parameter in a normal sentence.

    Line 549, Patchset 4 (Latest): // According to RFC 7234, "must-revalidate" takes precedence over
    Adam Rice . unresolved

    I think it's better if the caller implements this restriction. Consider a header like
    ```
    Cache-Control: stale-while-revalidate=30, must-revalidate
    ```
    In this case this function would set `stale_while_revalidate` even though `must-revalidate` was present. It would be good to add a test to http_response_headers_unittest.cc for this case.

    Line 538, Patchset 4 (Latest): inline void ParseCacheControlDirectivesForFreshness(
    Adam Rice . unresolved
    Prefer using return values over output parameters (see https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). In this case it's best to define a struct like
    ```
    struct CacheControlFreshnessDirectives {
    bool must_revalidate;
    std::optional<base::TimeDelta> max_age_value;
    std::optional<base::TimeDelta> stale_while_revalidate;
    };
    ```
    Line 523, Patchset 4 (Latest): inline bool HasCacheRestriction() const {
    Adam Rice . unresolved

    We don't normally inline complex functions in Chromium code. For production builds we use full program optimisation, so the compiler can inline across translation units if it needs to. Placing functions in headers tends to lead to unnecessary inlining by the compiler, leading to binary bloat and worse performance. See https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++.md#inline-functions

    File net/http/http_response_headers.cc
    Line 934, Patchset 4 (Latest): while (start < end && *start == ' ') {
    // leading spaces
    ++start;
    }
    while (start < end - 1 && *(end - 1) == ' ') {
    // trailing spaces
    --end;
    }
    Adam Rice . unresolved

    I realise this code was there originally, but it is not very clear. I suggest doing something like
    ```
    value = base::TrimString(value, " ", base::TRIM_ALL);
    ```

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Maks Orlovich
    • Mayur Patil
    • suresh potti
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
    Gerrit-Change-Number: 6310135
    Gerrit-PatchSet: 4
    Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
    Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
    Gerrit-CC: suresh potti <sures...@microsoft.com>
    Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
    Gerrit-Attention: Mayur Patil <patil...@microsoft.com>
    Gerrit-Attention: suresh potti <sures...@microsoft.com>
    Gerrit-Comment-Date: Tue, 04 Mar 2025 07:24:32 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Mar 4, 2025, 2:26:07 AM3/4/25
    to Mayur Patil, suresh potti, Maks Orlovich, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Maks Orlovich, Mayur Patil and suresh potti

    Adam Rice added 1 comment

    Patchset-level comments
    Maks Orlovich . unresolved

    ...Have you actually measured this?

    Mayur Patil

    Thanks for suggesting this point Maks...

    I added a simple Logger to verify Time difference in NanoSeconds for one Parameterized Test Case (RequiresValidationTest.RequiresValidation)...

    Added below snippet:

          const auto startTime =  base::TimeTicks::Now();
    FreshnessLifetimes lifetimes = GetFreshnessLifetimes(response_time);
    const auto endTime = base::TimeTicks::Now();
    LOG(INFO) << "Time difference = " << (endTime - startTime).InNanoseconds();

    Performance of HasHeaderValue lookup is still better compared to storage based lookup validation...

    Performance:-
    HasHeaderValue < Changes without vector while creating flat_set object < Changes with vector while creating flat_set object

    with HasHeaderValue lookup 5 times been highest performant...

    Adam Rice

    Thanks for doing this measurement! It looks like we are losing so much time from doing the memory allocation for the flat_set that it is cancelling out any benefit from reducing the number of string comparisons.

    I suggest giving up on the generic approach and just having a single `EnumerateHeader()` loop in `GetFreshnessLifetimes()` that checks for all 5 strings at the same time.

    Mayur Patil

    I have added variables to store computed values.

    Upon reviewing the test results, I noticed an improvement compared to the current values. However, the scope of testing was limited to the RequiresValidation Test Case in this scenario.

    I have a few queries:

    The methods GetMaxAgeValue() and GetStaleWhileRevalidateValue() internally call private method GetCacheControlDirective(). These methods are now only used in test cases. Should we consider removing them and modifying the test cases if these changes are good to go?

    Adam Rice

    Yes, if `GetMaxAgeValue()` and `GetStaleWhileRevalidateValue()` are only used in test cases, please delete them.

    Gerrit-Comment-Date: Tue, 04 Mar 2025 07:25:58 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mayur Patil (Gerrit)

    unread,
    Mar 4, 2025, 12:53:02 PM3/4/25
    to suresh potti, Maks Orlovich, Adam Rice, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Adam Rice, Maks Orlovich and suresh potti

    Mayur Patil added 7 comments

    Patchset-level comments
    File-level comment, Patchset 2:
    Maks Orlovich . resolved

    ...Have you actually measured this?

    Mayur Patil

    Thanks for suggesting this point Maks...

    I added a simple Logger to verify Time difference in NanoSeconds for one Parameterized Test Case (RequiresValidationTest.RequiresValidation)...

    Added below snippet:

          const auto startTime =  base::TimeTicks::Now();
    FreshnessLifetimes lifetimes = GetFreshnessLifetimes(response_time);
    const auto endTime = base::TimeTicks::Now();
    LOG(INFO) << "Time difference = " << (endTime - startTime).InNanoseconds();

    Performance of HasHeaderValue lookup is still better compared to storage based lookup validation...

    Performance:-
    HasHeaderValue < Changes without vector while creating flat_set object < Changes with vector while creating flat_set object

    with HasHeaderValue lookup 5 times been highest performant...

    Adam Rice

    Thanks for doing this measurement! It looks like we are losing so much time from doing the memory allocation for the flat_set that it is cancelling out any benefit from reducing the number of string comparisons.

    I suggest giving up on the generic approach and just having a single `EnumerateHeader()` loop in `GetFreshnessLifetimes()` that checks for all 5 strings at the same time.

    Mayur Patil

    I have added variables to store computed values.

    Upon reviewing the test results, I noticed an improvement compared to the current values. However, the scope of testing was limited to the RequiresValidation Test Case in this scenario.

    I have a few queries:

    The methods GetMaxAgeValue() and GetStaleWhileRevalidateValue() internally call private method GetCacheControlDirective(). These methods are now only used in test cases. Should we consider removing them and modifying the test cases if these changes are good to go?

    Adam Rice

    Yes, if `GetMaxAgeValue()` and `GetStaleWhileRevalidateValue()` are only used in test cases, please delete them.

    Mayur Patil

    it is use in http_cache_unittest & http_response_headers_unittests. keeping them to easily access EnumerateHeader method...

    Hence just added a comment stating they are meant for test purpose only

    File net/http/http_response_headers.h
    Line 567, Patchset 4: std::optional<base::TimeDelta> ParseCacheControlDirective(
    Adam Rice . resolved

    This calling convention is a bit confusing. I suggest you change the function to just expect a number like `"3600"` and then in the caller do `value->substr(kMaxAge.size())`. Then you can rename the function so something like `ParseSeconds()` or similar.

    Mayur Patil

    Done

    Line 563, Patchset 4: // @param directive_size The length of the directive name including the equals
    Adam Rice . resolved

    We don't normally use `@param` notation in Chromium code. I suggest just describing the parameter in a normal sentence.

    Mayur Patil

    Done

    Line 549, Patchset 4: // According to RFC 7234, "must-revalidate" takes precedence over
    Adam Rice . resolved

    I think it's better if the caller implements this restriction. Consider a header like
    ```
    Cache-Control: stale-while-revalidate=30, must-revalidate
    ```
    In this case this function would set `stale_while_revalidate` even though `must-revalidate` was present. It would be good to add a test to http_response_headers_unittest.cc for this case.

    Mayur Patil

    Done

    Line 538, Patchset 4: inline void ParseCacheControlDirectivesForFreshness(
    Adam Rice . resolved
    Prefer using return values over output parameters (see https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). In this case it's best to define a struct like
    ```
    struct CacheControlFreshnessDirectives {
    bool must_revalidate;
    std::optional<base::TimeDelta> max_age_value;
    std::optional<base::TimeDelta> stale_while_revalidate;
    };
    ```
    Mayur Patil

    Done

    Line 523, Patchset 4: inline bool HasCacheRestriction() const {
    Adam Rice . resolved

    We don't normally inline complex functions in Chromium code. For production builds we use full program optimisation, so the compiler can inline across translation units if it needs to. Placing functions in headers tends to lead to unnecessary inlining by the compiler, leading to binary bloat and worse performance. See https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++.md#inline-functions

    Mayur Patil

    Done

    File net/http/http_response_headers.cc
    Line 934, Patchset 4: while (start < end && *start == ' ') {

    // leading spaces
    ++start;
    }
    while (start < end - 1 && *(end - 1) == ' ') {
    // trailing spaces
    --end;
    }
    Adam Rice . resolved

    I realise this code was there originally, but it is not very clear. I suggest doing something like
    ```
    value = base::TrimString(value, " ", base::TRIM_ALL);
    ```

    Mayur Patil

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Adam Rice
    • Maks Orlovich
    • suresh potti
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
    Gerrit-Change-Number: 6310135
    Gerrit-PatchSet: 5
    Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
    Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
    Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
    Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
    Gerrit-CC: suresh potti <sures...@microsoft.com>
    Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
    Gerrit-Attention: Adam Rice <ri...@chromium.org>
    Gerrit-Attention: suresh potti <sures...@microsoft.com>
    Gerrit-Comment-Date: Tue, 04 Mar 2025 17:52:50 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Adam Rice (Gerrit)

    unread,
    Mar 5, 2025, 12:16:02 AM3/5/25
    to Mayur Patil, suresh potti, Maks Orlovich, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
    Attention needed from Maks Orlovich, Mayur Patil and suresh potti

    Adam Rice added 5 comments

    File net/http/http_response_headers.cc
    Line 931, Patchset 5 (Latest): auto start = value.cbegin();
    auto end = value.cend();
    if (start == end ||
    !std::all_of(start, end, [](char c) { return '0' <= c && c <= '9'; })) {
    return std::nullopt;
    }
    int64_t seconds = 0;
    base::StringToInt64(base::MakeStringPiece(start, end), &seconds);
    Adam Rice . unresolved
    `std::string_view` guarantees memory safety, so try to stay in the `std::string_view` world as much as possible. Like this:
    ```suggestion
    if (value.empty() ||
    !std::ranges::all_of(value, absl::is_digit)) {
    return std::nullopt;
    }
    int64_t seconds = 0;
    base::StringToInt64(value, &seconds);
    ```
    Line 1224, Patchset 5 (Latest): } else if (!directives.must_revalidate &&
    Adam Rice . unresolved

    I think it's better not to check `must_revalidate` here, since it doesn't work in every case. `GetFreshnessLifetimes()` already does the check correctly, so you can move the comment about RFC 7234 there.

    Line 1269, Patchset 5 (Latest): const auto& directives = ParseCacheControlDirectivesForFreshness();
    Adam Rice . unresolved
    You can make the code more concise with destructuring assignment:
    ```suggestion
    auto [must_revalidate, max_age, stale_while_revalidate] = ParseCacheControlDirectivesForFreshness();
    ```
    File net/http/http_response_headers_unittest.cc
    Line 2829, Patchset 5 (Latest): bool has_freshness;
    Adam Rice . unresolved

    `has_freshness` and `has_staleness` are not actually needed. You can just compare `freshness` and `staleness` directly. This will make the test cases easier to understand.

    Line 2850, Patchset 5 (Latest): EXPECT_TRUE(lifetimes.freshness > base::TimeDelta());
    Adam Rice . unresolved

    This check is redundant and should be removed (also it should be using `EXPECT_GT` for better diagnostics on failure).

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Maks Orlovich
    • Mayur Patil
    • suresh potti
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
      Gerrit-Change-Number: 6310135
      Gerrit-PatchSet: 5
      Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
      Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
      Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
      Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
      Gerrit-CC: suresh potti <sures...@microsoft.com>
      Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
      Gerrit-Attention: Mayur Patil <patil...@microsoft.com>
      Gerrit-Attention: suresh potti <sures...@microsoft.com>
      Gerrit-Comment-Date: Wed, 05 Mar 2025 05:15:55 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Mayur Patil (Gerrit)

      unread,
      Mar 6, 2025, 1:08:40 PM3/6/25
      to suresh potti, Maks Orlovich, Adam Rice, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
      Attention needed from Adam Rice, Maks Orlovich and suresh potti

      Mayur Patil added 5 comments

      File net/http/http_response_headers.cc
      Line 931, Patchset 5: auto start = value.cbegin();

      auto end = value.cend();
      if (start == end ||
      !std::all_of(start, end, [](char c) { return '0' <= c && c <= '9'; })) {
      return std::nullopt;
      }
      int64_t seconds = 0;
      base::StringToInt64(base::MakeStringPiece(start, end), &seconds);
      Adam Rice . resolved
      `std::string_view` guarantees memory safety, so try to stay in the `std::string_view` world as much as possible. Like this:
      ```suggestion
      if (value.empty() ||
      !std::ranges::all_of(value, absl::is_digit)) {
      return std::nullopt;
      }
      int64_t seconds = 0;
      base::StringToInt64(value, &seconds);
      ```
      Mayur Patil

      Done

      Line 1224, Patchset 5: } else if (!directives.must_revalidate &&
      Adam Rice . resolved

      I think it's better not to check `must_revalidate` here, since it doesn't work in every case. `GetFreshnessLifetimes()` already does the check correctly, so you can move the comment about RFC 7234 there.

      Mayur Patil

      yes, the condition was actually added to serve one purpose, to ignore computation of stale_while_revalidate in case must_revalidate is turned to true, to avoid extra steps for execution...

      eg : must-revlidate; stale-while-revalidate=20

      actual assignment of correct value is already taken care in GetFreshness Method....

      Line 1269, Patchset 5: const auto& directives = ParseCacheControlDirectivesForFreshness();
      Adam Rice . resolved
      You can make the code more concise with destructuring assignment:
      ```suggestion
      auto [must_revalidate, max_age, stale_while_revalidate] = ParseCacheControlDirectivesForFreshness();
      ```
      Mayur Patil

      Done

      File net/http/http_response_headers_unittest.cc
      Line 2829, Patchset 5: bool has_freshness;
      Adam Rice . resolved

      `has_freshness` and `has_staleness` are not actually needed. You can just compare `freshness` and `staleness` directly. This will make the test cases easier to understand.

      Mayur Patil

      Done

      Line 2850, Patchset 5: EXPECT_TRUE(lifetimes.freshness > base::TimeDelta());
      Adam Rice . resolved

      This check is redundant and should be removed (also it should be using `EXPECT_GT` for better diagnostics on failure).

      Mayur Patil

      Acknowledged

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Adam Rice
      • Maks Orlovich
      • suresh potti
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
      Gerrit-Change-Number: 6310135
      Gerrit-PatchSet: 6
      Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
      Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
      Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
      Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
      Gerrit-CC: suresh potti <sures...@microsoft.com>
      Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
      Gerrit-Attention: Adam Rice <ri...@chromium.org>
      Gerrit-Attention: suresh potti <sures...@microsoft.com>
      Gerrit-Comment-Date: Thu, 06 Mar 2025 18:08:06 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Adam Rice <ri...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Adam Rice (Gerrit)

      unread,
      Mar 7, 2025, 3:23:28 AM3/7/25
      to Mayur Patil, suresh potti, Maks Orlovich, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
      Attention needed from Maks Orlovich, Mayur Patil and suresh potti

      Adam Rice voted and added 1 comment

      Votes added by Adam Rice

      Code-Review+1

      1 comment

      Patchset-level comments
      File-level comment, Patchset 6 (Latest):
      Adam Rice . resolved

      lgtm, thank you for fixing everything!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Maks Orlovich
      • Mayur Patil
      • suresh potti
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
      Gerrit-Change-Number: 6310135
      Gerrit-PatchSet: 6
      Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
      Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
      Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
      Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
      Gerrit-CC: suresh potti <sures...@microsoft.com>
      Gerrit-Attention: Maks Orlovich <morl...@chromium.org>
      Gerrit-Attention: Mayur Patil <patil...@microsoft.com>
      Gerrit-Attention: suresh potti <sures...@microsoft.com>
      Gerrit-Comment-Date: Fri, 07 Mar 2025 08:23:13 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Maks Orlovich (Gerrit)

      unread,
      Mar 7, 2025, 9:50:52 AM3/7/25
      to Mayur Patil, Nidhi Jaju, Adam Rice, suresh potti, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
      Attention needed from Mayur Patil, Nidhi Jaju and suresh potti

      Maks Orlovich voted and added 2 comments

      Votes added by Maks Orlovich

      Code-Review+1

      2 comments

      Patchset-level comments
      Maks Orlovich . resolved

      How much did this end up helping?

      File net/http/http_response_headers.h
      Line 376, Patchset 5: // should not be used in production code.
      Maks Orlovich . unresolved

      ...You could rename it to GetMaxAgeValueForTesting() to help ensure that.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Mayur Patil
      • Nidhi Jaju
      • suresh potti
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
      Gerrit-Change-Number: 6310135
      Gerrit-PatchSet: 6
      Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
      Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
      Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
      Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
      Gerrit-Reviewer: Nidhi Jaju <nidh...@chromium.org>
      Gerrit-CC: suresh potti <sures...@microsoft.com>
      Gerrit-Attention: Nidhi Jaju <nidh...@chromium.org>
      Gerrit-Attention: Mayur Patil <patil...@microsoft.com>
      Gerrit-Attention: suresh potti <sures...@microsoft.com>
      Gerrit-Comment-Date: Fri, 07 Mar 2025 14:50:37 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Mayur Patil (Gerrit)

      unread,
      Mar 7, 2025, 11:02:13 AM3/7/25
      to Maks Orlovich, Nidhi Jaju, Adam Rice, suresh potti, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
      Attention needed from Nidhi Jaju and suresh potti

      Mayur Patil voted Commit-Queue+2

      Commit-Queue+2
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Nidhi Jaju
      • suresh potti
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
      Gerrit-Change-Number: 6310135
      Gerrit-PatchSet: 6
      Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
      Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
      Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
      Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
      Gerrit-Reviewer: Nidhi Jaju <nidh...@chromium.org>
      Gerrit-CC: suresh potti <sures...@microsoft.com>
      Gerrit-Attention: Nidhi Jaju <nidh...@chromium.org>
      Gerrit-Attention: suresh potti <sures...@microsoft.com>
      Gerrit-Comment-Date: Fri, 07 Mar 2025 16:01:56 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Mayur Patil (Gerrit)

      unread,
      Mar 7, 2025, 11:02:15 AM3/7/25
      to Maks Orlovich, Nidhi Jaju, Adam Rice, suresh potti, Chromium LUCI CQ, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org
      Attention needed from Nidhi Jaju and suresh potti

      Mayur Patil added 1 comment

      File net/http/http_response_headers.h
      Line 376, Patchset 5: // should not be used in production code.
      Maks Orlovich . resolved

      ...You could rename it to GetMaxAgeValueForTesting() to help ensure that.

      Mayur Patil

      GetMaxAgeValue & StaleWhileRevalidate are used in 2 files at multiple instancees... To avoid those changes I did not renamed them and added just a comment stating method not be used in production....

      I think it should be sufficient enough....

      Gerrit-Comment-Date: Fri, 07 Mar 2025 16:01:49 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Maks Orlovich <morl...@chromium.org>
      satisfied_requirement
      open
      diffy

      Chromium LUCI CQ (Gerrit)

      unread,
      Mar 7, 2025, 11:19:27 AM3/7/25
      to Mayur Patil, Maks Orlovich, Nidhi Jaju, Adam Rice, suresh potti, chromium...@chromium.org, edgen...@microsoft.com, gavin...@chromium.org, net-r...@chromium.org

      Chromium LUCI CQ submitted the change

      Change information

      Commit message:
      Refactor GetFreshnessLifetimes to Extract Cache-Control Once

      Refactored the HttpResponseHeaders::GetFreshnessLifetimes method to
      improve efficiency by extracting and parsing the Cache-Control header
      values only once. This change eliminates the need to loop for
      Cache-Control header in the header list, reducing redundant operations
      and enhancing overall performance.
      Bug: 399272772
      Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
      Commit-Queue: Mayur Patil <patil...@microsoft.com>
      Reviewed-by: Maks Orlovich <morl...@chromium.org>
      Reviewed-by: Adam Rice <ri...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#1429526}
      Files:
      • M net/http/http_response_headers.cc
      • M net/http/http_response_headers.h
      • M net/http/http_response_headers_unittest.cc
      Change size: M
      Delta: 3 files changed, 190 insertions(+), 56 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Adam Rice, +1 by Maks Orlovich
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I8d330ffa6d8787b3e83f43d033666fd836de7752
      Gerrit-Change-Number: 6310135
      Gerrit-PatchSet: 7
      Gerrit-Owner: Mayur Patil <patil...@microsoft.com>
      Gerrit-Reviewer: Adam Rice <ri...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Maks Orlovich <morl...@chromium.org>
      Gerrit-Reviewer: Mayur Patil <patil...@microsoft.com>
      Gerrit-Reviewer: Nidhi Jaju <nidh...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages